#pragma once

#include <iostream>
#include <string>
#include <cstdarg>
#include <ctime>
#include <stdio.h>
using namespace std;

enum
{
    Debug = 0,
    Info,
    warning,
    Error,
    Fatal
};


string LevelToString(int level)
{
    switch(level)
    {
        case Debug:
            return "Debug";
        case Info:
            return "Info";
        case warning:
            return "warning";
        case Error:
            return "Error";
        case Fatal:
            return "Fatal";
        default:
            return "unkown";
    }
}

class Log
{
public:
    Log(){}

    void LogMessage(int level, const char* format, ...)
    {
        char content[1024];
        va_list args;//可变参数
        va_start(args, format);
        vsnprintf(content, sizeof(content), format, args);
        va_end(args);
        uint64_t currtime = time(nullptr);
        printf("[%s][%s]%s\n", LevelToString(level).c_str(), 
                to_string(currtime).c_str(), content);
    }

    ~Log(){}
private:    
};